package controller.parents;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 家长页面跳转控制
 */
@Controller
@RequestMapping(value = "/parents")
public class ParentsPageController {

    /**
     * 家长控制台主页
     */
    @GetMapping("/console")
    public ModelAndView parentsConsolePage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("ParentsInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/parents/Console.jsp");

        return modelAndView;
    }

    /**
     * 家长框架主页
     */
    @GetMapping("/frame/index")
    public ModelAndView parentsFrameIndexPage(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/jsp/parents/Frame-Index.jsp");
        return modelAndView;
    }

    /**
     * 家长信息界面
     */
    @GetMapping("/frame/personalInfo")
    public ModelAndView parentsInfoPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("ParentsInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/parents/Frame-PersonalInfo.jsp");

        return modelAndView;
    }

    /**
     * 家长修改基础信息页
     */
    @GetMapping("/frame/alterBaseInfo")
    public ModelAndView parentsAlterBaseInfoPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("ParentsInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/parents/Frame-ChangeBaseInfo.jsp");

        return modelAndView;
    }

    /**
     * 家长修改登录信息页
     */
    @GetMapping("/frame/alterLogin")
    public ModelAndView parentsAlterLoginInfoPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("ParentsInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/parents/Frame-ChangeLoginInfo.jsp");

        return modelAndView;
    }

    /**
     * 家长修改联系信息页
     */
    @GetMapping("/frame/alterConn")
    public ModelAndView parentsAlterConnInfoPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("ParentsInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/parents/Frame-ChangeConnectInfo.jsp");

        return modelAndView;
    }

    /**
     * 家长课程信息页
     */
    @GetMapping("/frame/my-course")
    public String parentsClassInfoPage(){
        return "forward:/pages/parents/Console-Frame-ClassInfo.html";
    }

    /**
     * 家长修改头像信息页
     */
    @GetMapping("/frame/alter-avatar-page")
    public String parentsAlterAvatarPage(){
        return "forward:/pages/parents/Console-Frame-UpdateAvatar.html";
    }
}
